<div class="title-body-content"><?php echo $title_for_layout; ?></div>
<?php
if($rel == 'browse') {
    $formUrl = array('controller' => 'banks', 'action' => 'add', 'rel' => 'browse');
} else {
    $formUrl = array('controller' => 'banks', 'action' => 'add');
}
echo $this->Form->create('Bank', array('url' => $formUrl, 'type' => 'text'));
?>
<div class="wrapper-form-broking clearfix">
    <div class="wrapper-broking-inquyri clearfix">
        <div class="wrapper-inquirer clearfix">
            <span class="sp-bank-title"><?php echo __('Bank Name'); ?> (*):</span>
            <?php
            echo $this->Form->input('name', array(
                'class' => 'inp-bank-name',
                'label' => false,
                'div' => false,)
            );
            ?>
        </div>

        <div class="wrapper-bank-content clearfix">
            <span class="sp-bank-title-bank-address"><?php echo __('Bank Address'); ?> :</span>
            <?php
            echo $this->Form->textarea('address', array(
                'class' => 'inp-contact-address',
                'label' => false,
                'div' => false,)
            );
            ?>
        </div>
        
        <div class="wrapper-bank-content clearfix">
            <span class="sp-bank-title"><?php echo __('Bank Account'); ?> (*):</span>
            <?php
            echo $this->Form->input('account', array(
                'class' => 'inp-bank-acc',
                'label' => false,
                'div' => false,)
            );
            ?>
            <span id="exsisterror"></span>
        </div>
        
        <div class="wrapper-bank-content clearfix">
            <span class="sp-bank-title"><?php echo __('Bank Account Name'); ?> :</span>
            <?php
            echo $this->Form->input('bank_account_name', array(
                'class' => 'inp-bank-name',
                'label' => false,
                'div' => false,)
            );
            ?>
            <span id="exsisterror"></span>
        </div>
        
        <div class="wrapper-bank-content clearfix">
            <span class="sp-bank-title"><?php echo __('SWIFT'); ?> (*):</span>
            <?php
            echo $this->Form->input('swift_code', array(
                'class' => 'inp-bank-acc',
                'label' => false,
                'div' => false,)
            );
            ?>
          
        </div>  
        
        <div class="wrapper-bank-content clearfix">
            <span class="sp-bank-title"><?php echo __('Currency'); ?> (*):</span>
            <?php
            echo $this->Form->input('Currency.Currency', array(
                'multiple' => false,
                'selected' => 3,
                'empty' => false,
                'label' => false,
                'div' => false,)
            );
            ?>
          
        </div>  
    </div>
</div>

<!-- HTML for buttom -form-->

<div class="wrapper-button-form">
    <div class="button-form">
        <div class="button-aihre button-blue"><a href="#" class="save">SAVE</a></div>
        <div class="button-aihre button-blue">
            <?php
            if ($rel == 'browse') {
                echo $this->Html->link(__('CANCEL'), array('plugin' => null, 'controller' => 'banks', 'action' => 'browse'));
            } else {
                echo $this->Html->link(__('CANCEL'), array('plugin' => null, 'controller' => 'banks', 'action' => 'index'));
            }
            ?>
        </div>
    </div>
</div>
<?php
echo $this->Form->end();
?>
<?php
$validForm = "
    $(function(){
        $('a.save').click(function(){
            $.getJSON('" . Router::url('/admin/banks/checkbankaccunique/', true) . "'+$('#BankAccount').val(), function(data) {
                if(data.success){
                    if(data.isExsist === '1'){
                        $('#exsisterror').html('This bank account has existed.');
                        $('#exsisterror').attr('style','color:red');
                    }else{
                        $('#exsisterror').removeAttr('style');
                        $('#exsisterror').html('');
                        $('#BankAdminAddForm').submit();
                    }
                } else {
                    // error
                }
            });
        });
    });";
$this->Html->scriptBlock($validForm, array('inline' => false));
?>